package com.zhiqihang.ziqihangserverorders.service.impl;

import com.zhiqihang.order.OrderCode;
import com.zhiqihang.order.Orders;
import com.zhiqihang.result.JsonResult;
import com.zhiqihang.ziqihangserverorders.repository.OrderRepository;
import com.zhiqihang.ziqihangserverorders.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Optional;

/**
 * @ClassName OrderServiceImpl
 * @Description Violet
 * @Author 86183
 * @Date 2024/7/17 9:09
 * @Version 1.0
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderRepository orderRepository;

    @Override
    public JsonResult findAll() {
        List<Orders> all = orderRepository.findAll();
        return new JsonResult(OrderCode.ORDER_FOUND,all);
    }

    @Override
    public JsonResult add(Orders orders) {
        orders.setCreateTime(new Date());
        orders.setStatus("0");
        orders.setPayee("智启航教育");
        orderRepository.save(orders);
        return JsonResult.ok(OrderCode.ORDER_FOUND,null);
    }

}
